package com.test;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import net.sf.json.JSONObject;

public class T {
	public static void main(String[] args) throws IOException {
		String url = "http://www.baidu.com/s?wd=site:(www.zybang.com)&rn=50";
		Document doc = Jsoup.connect(url).get();
		Elements divs = doc.select("div#content_left div[data-tools]");
		for (Element element : divs) {
			String json = element.attr("data-tools");
			if(json!=null && json.trim().startsWith("{")){
				//获取到json
				JSONObject jsonObj = JSONObject.fromObject(json.trim());
				//获取url
				String durl = jsonObj.getString("url");//内容url
				//do something
				System.out.println(durl);
			}
		}
	}
}
